<?php
/**
 * 钻石投票模块-后台管理-编辑
 *
 * @author 天涯织梦
 * @url http://bbs.we7.cc/
 */

defined('IN_IA') or exit('Access Denied');

load()->func('file');
load()->func('tpl');
global $_W,$_GPC;
$uniacid = intval($_W['uniacid']);
$id = intval($_GPC['id']);
$rid=intval($_GPC['rid']);
$votedata = pdo_fetch("SELECT * FROM " . tablename($this->tablevoteuser) . " WHERE  id = :id AND uniacid = :uniacid AND rid = :rid", array(':id' => $id,':uniacid' => $uniacid,':rid' => $rid));
$options=array('width'=>80,'height' => 80);

if ($_W['ispost']) {


	if (empty($_GPC['name'])) {
		message('名字不能为空');
	}
	if (empty($_GPC['mobile'])) {
		message('手机不能为空');
	}


         $instdata = array(
			'rid'=>$rid,
			'uniacid'=>$_W['uniacid'],
			'avatar'=>$_GPC['avatar'], 
			'sex'=>$_GPC['sex'], 
			'name'=>$_GPC['name'],
			'mobile' =>$_GPC['mobile'],
			'introduction' =>$_GPC['introduction'],
			'img1'=>$_GPC['img1'],
			'img2'=>$_GPC['img2'],
			'img3'=>$_GPC['img3'],
			'img4'=>$_GPC['img4'],
			'img5'=>$_GPC['img5'],
			'votenum'=>$_GPC['votenum'],
			'diamondnum'=>$_GPC['diamondnum'],
			'status'=>$_GPC['status'],
		);



	if (!empty($votedata['id'])) {
		pdo_update($this->tablevoteuser, $instdata, array('id' => $votedata['id']));

	} else {
        $instdata['createtime']=time();
		pdo_insert($this->tablevoteuser, $instdata);

	}			

	message('活动设置成功！', $this->createWebUrl('votelist', array('name' => 'tyzm_diamondvote','rid'=>$rid)), 'success');



}

include $this->template('create');


















